#ifndef ERROR_H__
#define ERROR_H__

#include <stdint.h>

typedef uint8_t ErrCode;

#define COMMON_ERR_BASE 0

/* non error */
#define E_SUCCESS (COMMON_ERR_BASE + 0)
/* common error code */
#define E_FAILURE (COMMON_ERR_BASE + 1)
/* got a invalid parameter */
#define E_PARAM (COMMON_ERR_BASE + 2)
/* apply memory failed */
#define E_NO_MEM (COMMON_ERR_BASE + 3)
/* apply resource failed except memory */
#define E_NO_RESRC (COMMON_ERR_BASE + 4)
/* resource is busy, for example, bus is busy,a mutex lock is busy*/
#define E_BUSY (COMMON_ERR_BASE + 5)
#define E_TIMEOUT (COMMON_ERR_BASE + 6)
/* hardware errors such as invalid bus state */
#define E_HARDWARE (COMMON_ERR_BASE + 7)
/* state is invalid for current operation */
#define E_INVALID_STATE (COMMON_ERR_BASE + 8)
/* current state is same with new state */
#define E_SAME_STATE (COMMON_ERR_BASE + 9)
/* invalid event id or operation code */
#define E_INVALID_CMD (COMMON_ERR_BASE + 10)
/* prevent action as system exceptions */
#define E_EXCEPTION (COMMON_ERR_BASE + 11)

#define DATA_LINK_ERR_BASE (COMMON_ERR_BASE + 190)
/* didn't found SOF in RX buffer */
#define E_NO_SOF (DATA_LINK_ERR_BASE + 0)
/* cannot get header in RX buffer */
#define E_NO_HEADER (DATA_LINK_ERR_BASE + 1)
/* incorrect checksum for data length
 * or it is out of range */
#define E_INVALID_DATA_LENGTH (DATA_LINK_ERR_BASE + 2)
/* cannot get data field in RX buffer */
#define E_NO_DATA (DATA_LINK_ERR_BASE + 3)
/* incorrect checksum of data  */
#define E_INVALID_DATA (DATA_LINK_ERR_BASE + 2)

#define PRIVATE_ERROR_BASE 200
#define E_NO_SWITCHING_STA (PRIVATE_ERROR_BASE + 0)
#define E_NO_WORKING (PRIVATE_ERROR_BASE + 1)
#define E_NO_FILAMENT (PRIVATE_ERROR_BASE + 2)
#define E_DOOR_OPENED (PRIVATE_ERROR_BASE + 3)
#define E_REJECT_SYNC_WRITE (PRIVATE_ERROR_BASE + 4)
#define E_AUTO_PROBING (PRIVATE_ERROR_BASE + 5)
#define E_IS_HOMING (PRIVATE_ERROR_BASE + 6)
#define E_NO_HOMED (PRIVATE_ERROR_BASE + 7)

#endif